/*
 * Developer : Jack Matthews
 * Email: developer@droidprofessor.com
 * 
 * Copyright (C) 2010 http://droidprofessor.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.droidprofessor.android.licensegenerator.client;

import java.io.File;
import java.net.URI;

import com.droidprofessor.licensegenerator.lib.CoreClientLicense;

import android.content.Context;



public interface AndroidClientLicense extends CoreClientLicense {

	
	/**
	 * Call this function when your application is first loaded.
	 * It only needs to be called once.
	 * 
	 * @param cnx use getApplicationContext()
	 * @param restriction locks the payments system according to the specified restriction, ie. Android Market not allowing 3rd party payment processing
	 * @param licensingSystem the licensing version used
	 * @param authKey an authentication key sent back to the server to validate the request
	 * @param salt a random string to help further encrypt user details, need to stay the same for all future applications
	 * @param base64PublicKey the application public key
	 * @param signatureFileName the name of the file that will store the license
	 * @param applicationId the id of this application from the Joomla Database
	 * @param the scheme to use http or https
	 * @param host Joomla hostname as in 'mydomain.com'
	 * @param port the port that Joomla is running on, usually 80
	 * @param path the path to the index.php in the Joomla Root.
	 */
	public void init(
			Context cnx,
			LicenseType restriction,
			String licensingSystem, 
			String authKey,
			String salt, 
			String base64PublicKey,
			String signatureFileName,
			String applicationId,
			String scheme,
			String host,
			String port, 
			String path
			);


	/**
	 * Attempts to download the license file forcibly overwriting
	 * any existing file.
	 * 
	 * You may want to use this option on a button or menu item
	 */
	public void downloadAndInstallLicense(Context cnx);

	/**
	 * Remove the account details from the preferences
	 */
	public void deleteAccountDetails(Context cnx);

	/**
	 * Delete license that is currently installed
	 * 
	 */
	public void deleteLicense(Context cnx);

	/**
	 * Determine is a license has been downlaoded
	 * 
	 * @return true if a license is installed
	 */
	public boolean isLicenseInstalled(Context cnx);


	/**
	 * Creates a visually friendly version of the license.
	 * The attributes a visual design may vary in future releases
	 * and should not be relied on.
	 * 
	 * @return a visually friendly version of the license details
	 */
	public String getLicenseDetails(Context cnx);


	/**
	 * The hostname for the joomla website provider
	 * 
	 * @return hostname
	 */
	public String getHost();


	/**
	 * The path to the Joomla root folder
	 * 
	 * @return path
	 */
	public String getPath();


	/**
	 * The port the Joomla site is running on
	 * 
	 * @return port number
	 */
	public int getPort();


	/**
	 * The application id number
	 * 
	 * @return an id number
	 */
	public String getApplicationId();


	/**
	 * Get the license File
	 * 
	 * @return the current license File
	 */
	public File getLicenseFile(Context cnx);


	/**
	 * Reload the license details
	 * 
	 * If a new license has been downloaded, this methods should
	 * be called.
	 * 
	 */
	public void reload(Context cnx);
	
	
	/**
	 * Get the salt used to encrypt data
	 * 
	 * @return salt
	 */
	public String getSalt();

	
	/**
	 * Get Joomla Authentication Key
	 * 
	 * This key is delivered to the server to ensure it came from a 
	 * device and is not a spam request.  The authKey should be kept 
	 * private.
	 * 
	 * @return authentication key
	 */
	public String getAuthKey();
	
	
	/**
	 * The Scheme to use
	 * 
	 * http or https
	 * 
	 * @return scheme
	 */
	public String getScheme();
	
	
	/**
	 * Return the ApplicationType enum
	 * 
	 * @return ApplicationType
	 */
	public LicenseType getLicenseType();


	
	/**
	 * Gets the full Joomla website link
	 * 
	 * @return full website link as a URI
	 */
	public URI getWebsiteUri();	
	

	/**
	 * Link to the products URI
	 * 
	 * @return products URI
	 */
	public URI getCrossPromotionUri();
}
